const http = require("http");
//try catch只能捕获到同步代码中的异常
try{
    http.createServer((req,res)=>{
    //var str = "hello world!"
    res.end(str);
    }).listen(8081);
    console.log("server is listening 8081");
}catch(error){
    console.log(error.message);
    console.log(error.constructor.name);
}
//用于全局捕获异常，可以捕获到异步代码的异常
process.on("uncaughtException",(err)=>{
    console.log(err.message);
    console.log(err.constructor.name);
})
